<?php

namespace App\Http\Controllers;

use App\Models\Law\Order;
use App\Services\QuestionService;

class TestController extends Controller
{
    public function index()
    {
        $list = Order::query()->orderBy('id')->limit(10)->get();

        // foreach ($list as $value) {
        //     QuestionService::create([
        //         'user_source_id'              => $value['user_id'],//  来源用户id
        //         'user_name'                   => $value['user_id'],//  用户名称
        //         'question_title'              => '',//  提问标题
        //         'question_content'            => '',//  提问内容
        //         'question_source'             => '',//  来源
        //         'law_order_category_one_name' => '',//  一级类别
        //         'law_order_category_two_name' => '',//  二级类别
        //         'law_order_money'             => '',//  涉案金额
        //         'law_order_source_id'         => '',//  来源id
        //         'comment_content'             => '',//  评论内容
        //     ]);
        // }
    }

    public function aaa($info) {
        $info = json_decode($info, true);

        $res = [];
        $res[] = $this->bbb("案件类型", ($info['type'] ?? '暂无'));
        $res[] = $this->bbb("案件子类型", ($info['category_twe_name'] ?? '暂无'));
        if (isset($info['type']) && $info['type'] == "刑事案件") {
            $res[] = $this->bbb("案发地", ($info['address'] ?? '暂无'));
        } else if (isset($info['type']) && $info['type'] == "经济纠纷") {
            $res[] = $this->bbb("案发地", ($info['address'] ?? '暂无'));
            $res[] = $this->bbb("涉及金额", ($info['money'] ?? '暂无'));
        } else if (isset($info['type']) && $info['type'] == "离婚纠纷") {
            $res[] = $this->bbb("案发地", ($info['address'] ?? '暂无'));
            $res[] = $this->bbb("子女", ($info['offspring'] ?? '暂无'));
            $res[] = $this->bbb("共同债务", ($info['debt'] ?? '暂无'));
            $res[] = $this->bbb("共同债务", ($info['debt'] ?? '暂无'));
            $res[] = $this->bbb("涉及金额", ($info['money'] ?? '暂无'));
        } else if (isset($info['type']) && $info['type'] == "债务逾期") {
            $res[] = $this->bbb("案发地", ($info['address'] ?? '暂无'));
            $res[] = $this->bbb("逾期平台名称", ($info['overdueplatform'] ?? '暂无'));
            $res[] = $this->bbb("涉及金额", ($info['money'] ?? '暂无'));
            $res[] = $this->bbb("逾期时长", ($info['overduetime'] ?? '暂无'));
        } else if (isset($info['type']) && $info['type'] == "劳动仲裁") {
            $res[] = $this->bbb("案发地", ($info['address'] ?? '暂无'));
            $res[] = $this->bbb("涉及金额", ($info['money'] ?? '暂无'));
            $res[] = $this->bbb("是否签署劳动/劳务合同", ($info['contract'] ?? '暂无'));
            $res[] = $this->bbb("工资发放的银行流水", ($info['salarywater'] ?? '暂无'));
            $res[] = $this->bbb("劳动/劳务合同解除通知书", ($info['contractinform'] ?? '暂无'));
        } else if (isset($info['type']) && $info['type'] == "工伤纠纷") {
            $res[] = $this->bbb("用工单位所在地", ($info['address'] ?? '暂无'));
            $res[] = $this->bbb("涉及金额", ($info['money'] ?? '暂无'));
            $res[] = $this->bbb("是否签署劳动/劳务合同", ($info['contract'] ?? '暂无'));
            $res[] = $this->bbb("劳动/劳务合同解除通知书", ($info['contractinform'] ?? '暂无'));
            $res[] = $this->bbb("工资发放的银行流水", ($info['salarywater'] ?? '暂无'));
        } else if (isset($info['type']) && $info['type'] == "劳动纠纷") {
            $res[] = $this->bbb("纠纷所在地", ($info['address'] ?? '暂无'));
            $res[] = $this->bbb("涉及金额", ($info['money'] ?? '暂无'));
            $res[] = $this->bbb("是否签署劳动/劳务合同", ($info['contract'] ?? '暂无'));
            $res[] = $this->bbb("工资发放的银行流水", ($info['salarywater'] ?? '暂无'));
            $res[] = $this->bbb("劳动/劳务合同解除通知书", ($info['contractinform'] ?? '暂无'));
        } else if (isset($info['type']) && $info['type'] == "房产纠纷") {
            $res[] = $this->bbb("纠纷所在地", ($info['address'] ?? '暂无'));
            $res[] = $this->bbb("涉及金额", ($info['money'] ?? '暂无'));
        } else if (isset($info['type']) && $info['type'] == "退费纠纷") {
            $res[] = $this->bbb("所在地", ($info['address'] ?? '暂无'));
            // $res[] = $this->bbb("对方公司名称", ($info['employer'] ?? '暂无'));
            $res[] = $this->bbb("涉及金额", ($info['money'] ?? '暂无'));
        } else if (isset($info['type']) && $info['type'] == "交通事故") {
            $res[] = $this->bbb("事故发生地", ($info['address'] ?? '暂无'));
            $res[] = $this->bbb("涉及金额", ($info['money'] ?? '暂无'));
        } else if (isset($info['type']) && $info['type'] == "其他类型") {
            $res[] = $this->bbb("所在地", ($info['address'] ?? '暂无'));
            $res[] = $this->bbb("涉及金额", ($info['money'] ?? '暂无'));
        }

        $res[] = $this->bbb("大致情况", ($info['issue'] ?? '暂无'));
        $res[] = $this->bbb("诉求", ($info['appeal'] ?? '暂无'));
        $res[] = $this->bbb("年龄", ($info['age'] ?? '暂无'));
        $res[] = $this->bbb("年龄", ($info['degree'] ?? '暂无'));
        $res[] = $this->bbb("职业", ($info['work'] ?? '暂无'));
        $res[] = $this->bbb("所在地", ($info['address'] ?? '暂无'));

        return implode("\n", $res);
    }

    public function bbb($title, $content) {
        $res = "<p style=\"box-sizing: border-box; margin: 0px 0px 20px; line-height: inherit; overflow-wrap: break-word; white-space-collapse: preserve; color: #1a1a1a; font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Microsoft YaHei', 'Source Han Sans SC', 'Noto Sans CJK SC', 'WenQuanYi Micro Hei', sans-serif; font-size: 15px;\"><span style=\"box-sizing: border-box; font-weight: bolder;\">".$title."：</span>".$content."</p>";
        return $res;
    }
}
